-
Notifications
You must be signed in to change notification settings - Fork 779
Implemented Color Mode channel for the Extended Color Light. #5762
Implemented Color Mode channel for the Extended Color Light. #5762
Conversation
New information channel but then what ? Except that I don't understand how it can help, the code LGTM. |
Same as @lolodomo, I do not understand the real use-case here. Independent of what mode the bulb is in, both color and color-temperature channels can be used, so UIs have the option to present the user any kind of UI. Any value that is sent as color-temperature can be shown as an HSB value on the color channel, so if the UI is in doubt, the color palette is always the safe option. |
@kaikreuzer and @lolodomo On one hand, the bulb itself returns the color mode (i.e. this information comes directly form the API) and, on the other hand, since this information is available straightforward, it does not make sense to always fall back to color palette relying on the calculated HSB value. Within the HUE app, for example, the user can choose to pick a color using a color temperature palette or a pure color palette. In the first case, the returned bulb's state denotes that the color has been set using the This is a natural UI behavior and other clients that utilize the HUE binding can make use of the color mode information. Finally, as said, this information comes in the bulb's state and I don't think it can be considered as a "UI preference". |
This is more a device property ? |
@lolodomo I guess it is more an item that can be used in conditional visibility in sitemaps, so that either a colorpicker for the color channel is shown OR a slider for the color-temperature. |
Yes - @kaikreuzer is right - an item is utilized to be used conditionally in order to show a colorpicker or a color-temperature slider. So, @lolodomo, I believe the case is now clarified? :) |
4e0c010
to
e2f7e68
Compare
I updated the PR with logic for creating the |
3f9e4f6
to
01d6ec9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small comment from my side in the code, please have a look.
@@ -125,6 +130,11 @@ private void initializeThing(@Nullable ThingStatus bridgeStatus) { | |||
if (getHueClient() != null) { | |||
if (bridgeStatus == ThingStatus.ONLINE) { | |||
initializeProperties(); | |||
|
|||
if (colorModeChannelRequired()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this logic? From the xml file I can tell that the 0210 thing has this channel, so why do you have this check and addition logic here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the returned bulb's state denotes that the color has been set using the color temperature scheme, while in the second case the bulb's state denotes the color has been set using the color scheme
Yeah, so in the end some color is set in the bulb (and that is its state).
this information comes in the bulb's state
Can you confirm that this information is indeed stored within the bulb? Is it available in any ZLL device that is connected to the hue bridge? If so, it should be mentioned in the ZLL specification, but I cannot find anything related. I'd therefore assume that it is something that is either specific to hue bulbs OR that the information is actually not stored in the device, but maintained in the hue bridge instead.
If this is a feature of the bridge that works for all devices that are connected to it, I'd be ok to accept this channel, although it brings the risk that UIs are built that are not working for any color light (e.g. LIFX, DMX, Lightify, Hue via Zigbee) in the same way, but which require product specific code. Are you sure that this is what you want?
and I don't think it can be considered as a "UI preference"
Why not? How would you call it instead? This information has no impact at all on how the bulb looks or behaves, or am I missing something?
I updated the PR with logic for creating the color_mode channel for an already paired thing of type 0210 (migration logic).
This must not be done within the binding. Either create a separate update logic externally in your own code or help implementing #2555, so that the framework deals with it across all bindings simultaneously.
This is part of the ZCL standard. Just for reference it's the issue that we had in ZigBee that I had to remove so I'm following this with interest :) openhab/org.openhab.binding.zigbee#41 |
Discussion in openhab/org.openhab.binding.zigbee#41 was also a lot about how to actually SEND commands to the bulbs and it actually listed three states ("Hue and Saturation", "X and Y" and "Color Temperature"). This also is related to #4939, where we see that the binding actually needs to send commands in different ways, but that should be something internal to the binding and not be exposed to the user. Do you possibly have a reference to the section in the spec at hand, where the exact meaning of that is described? |
I think there was some confusion and linking of the issues. The SENDING of commands needs to be done as the bulb supports - some bulbs support only XY (this is mandatory) some support Hue and some support another mode (I forget the name). The binding always takes care of this and sends the command as the bulb requires. The ZigBee issue was only about adding the
It is attribute 8 in the color control cluster -: There is also a newer "enhanced" attribute -: |
01d6ec9
to
cc99286
Compare
I agree and already reverted the changes considering channel creation within the
As already mentioned, the only ZLL device affected by the change is the Extended Color Light (0210) and I believe @cdjackson confirmed that the color mode is stored within the bulb's state and the color mode attribute has a mandatory value in the XY range (i.e. the XY value for color mode must always be available by specification). So, since I reverted the channel creation logic as you requested and the change does not violate the ZLL specification, can we give green light to the PR? |
How about leaving the migration logic here and creating a follow-up task to remove it once #2555 is complete ? (Because if not - we are blocking new features until something new is implemented - but it's not clear when /and even if/ this 'something' will ever be complete) |
It isn't in line with the specification either as it says that there can be 3 different values.
Can you confirm this, please?
Definitely not, because we all know that it will stay there forever. Rather help implementing #2555 or implement such a migration logic in your own code. |
I don't think this is correct. It should not interfere in any way the actual API call to the bridge |
Allow me to do make an alternative suggestion, which might be much more elegant and which would not interfere with how color bulbs are currently modelled in all the different bindings: The main issue is actually that the state of the CT channel is somehow not relevant/applicable, if the bulb shows some non-white color.
As a result, a UI could simply check the ct channel for NULL in order to determine whether it wants to show a colorpicker or a slider. The hue binding can internally use the color_mode attribute from the hue bridge to update the channel states accordingly. This would allow UIs to be fully compatible with all existing bindings in a generic way and not require any additional channels. Wdyt? /cc @cdjackson, @tomhoefer |
I see at least 2 drawbacks with this approach:
So - in general - this approach will be not very deterministic and there will be edge cases which will not work properly. |
|
Question: |
I don't think that this makes sense, because the color channel can always have a valid state and you always want to be able to display it in a color picker (e.g. if the user switches from slider to color picker). |
cc99286
to
f17f1b3
Compare
@kaikreuzer Please have a look again - I reverted all unnecessary changes and only implemented a logic for setting the |
f17f1b3
to
022eecb
Compare
public static @Nullable PercentType toColorTemperaturePercentType(State lightState) { | ||
ColorMode colorMode = lightState.getColorMode(); | ||
if (colorMode != null && !colorMode.equals(ColorMode.CT)) { | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning Java null
here won't work - what you have to do is to send a channel state update UnDefType.NULL
. Imho the best place to do the colorMode check would be here - simply do the update with PercentType it colorMode!=CT and otherwise do an updateState(CHANNEL_COLORTEMPERATURE, UnDefType.NULL);
.
Makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it makes sense - in such a way the toColorTemperaturePercentType()
method will remain untouched and will only do what it says - conversion. I will do the changes shortly.
Signed-off-by: Alexander Kostadinov <[email protected]>
022eecb
to
2e0ee32
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, what a nice little change - thanks!
This pull request has been mentioned on openHAB Community. There might be relevant details there: |
This pull request has been mentioned on openHAB Community. There might be relevant details there: |
This pull request has been mentioned on openHAB Community. There might be relevant details there: |
For all extended color lights (i.e. the
0210
ones that havecolor
andcolor_temperature
items), the Hue API returns information about the exact color mode the bulb is currently in. This information is used in the Hue app in order to display the RGB color palette (in case the API returned HS or XY color mode) or the color temperature palette (in case the API returned CT color mode).Since this is important UI-related information, a channel to hold the current color mode for
0210
bulb is implemented.